Skip to content

fix: edge case fixes based on codemod application#30

Merged
valerybugakov merged 1 commit intomainfrom
vb/css-modules-codemod-improvements
Sep 23, 2021
Merged

fix: edge case fixes based on codemod application#30
valerybugakov merged 1 commit intomainfrom
vb/css-modules-codemod-improvements

Conversation

@valerybugakov
Copy link
Copy Markdown
Member

@valerybugakov valerybugakov commented Sep 17, 2021

Context

Fixes added in process code-modding the main Sourcegraph repo with globalCssToCssModule codemod.

Changes

  • Handle case when CSS class is already inside of the classNames call in React component.
  • Handle non classNames props: e.g., contentClassName.
  • Preserve original order of styles in CSS module.
  • Ensure that redundant prefix is removed from the exportName: e.g., registryExtensionButton -> button.
  • Report unused CSS classes.
  • Remove empty root CSS class from CSS module.
  • Fix missing ; after last rule in the root CSS class.

@valerybugakov valerybugakov self-assigned this Sep 17, 2021
while (!areAllNodesProcessed) {
// `processNodesWithClassName` returns `true` when there's nothing more to process.
areAllNodesProcessed = processNodesWithClassName({
usageStats,
Copy link
Copy Markdown

@vovakulikov vovakulikov Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this idea about usage stats and reporting thing, Cool!

nextNode.replaceWith(parse(nextNodeValue.replace('__', '.')))

return true
/**
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool example

Copy link
Copy Markdown

@vovakulikov vovakulikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test that manually but unit tests look good.

@valerybugakov
Copy link
Copy Markdown
Member Author

Thanks, Vova!

@valerybugakov valerybugakov merged commit 2535ba2 into main Sep 23, 2021
@valerybugakov valerybugakov deleted the vb/css-modules-codemod-improvements branch September 23, 2021 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants